package lab02.Test17;

/**
 * Created by Administrator on 2017/11/17.
 */
public class Test17 {
    public static void main(String[] args) {
        double sum = 0;
        double max;
        double min;
        double[] nums = new double[10];
        nums[0] = 13;
        nums[1] = 10;
        nums[2] = 16;
        nums[3] = 19;
        nums[4] = 21;
        nums[5] = 29;
        nums[6] = 60;
        nums[7] = 70;
        nums[8] = 100;
        nums[9] = 24;
        max = nums[0];
        min = nums[0];
        for (int i = 0; i < nums.length; ) {
            max = max > nums[i] ? max : nums[i];
            min = min < nums[i] ? min : nums[i];
            sum += nums[i++];
        }

        System.out.println("和:" + sum);
        System.out.println("最大:" + max);
        System.out.println("最小:" + min);
        for (int i = nums.length - 1; i >= 0; i--) {
            if (max == nums[i]) {
                System.out.println("最大值位置：" + i);
            }
            if (min == nums[i]) {
                System.out.println("最小值位置：" + i);
            }
        }
    }
}
